import MyIcon from '../../../components/MyIcon'
import moment from 'moment'

export default {
  /**
   * 以下为区域管理相关数据
   * **/
  // 额外按钮
  extraBtnArea: [
    {
      name: '厂信息',
      icon: 'icon-fangzi_',
      iconStyle: {color:'#549FFF'},
      funName: 'factorClick'
    }
  ],
  // 搜索条件
  itemsArea(items) {
    return [
      {
        type: 'select',
        label: '区域名称:',
        placeholder: '请输入 ..',
        paramName: 'areaName',
        options: [{text: '全部', value: ''}, ...items]
      },
    ]
  },
  // 表格columns
  columnsArea(read, edit) {
    return [
      {
        dataIndex: 'num',
        key: 'num',
        title: '序号',
        width: 50
      },
      {
        dataIndex: 'areaName',
        key: 'areaName',
        title: '区域',
        width: 150
      },
      {
        dataIndex: 'tagType',
        key: 'tagType',
        title: '区域二维码',
        width: 150
      },
      {
        dataIndex: 'handle',
        key: 'handle',
        title: '操作',
        width: 80,
        render(text, record) {
          return (
            <div>
              <MyIcon type="icon-chakan" onClick={read.bind(this, record)}
                      style={{fontSize: 18, color: '#16b8be', verticalAlign: 'center'}}/>
              <span style={{position: 'relative', bottom: 2}}> | </span>
              <MyIcon type="icon-bianji"
                      onClick={edit.bind(this, record)}
                      style={{
                        fontSize: 18,
                        color: '#16b8be',
                        marginLeft: 2
                      }}/>
            </div>

          )
        }
      },
    ]
  },

  // 模态框数据;
  itemsModalArea(initDataArea) {
    return [
      {
        title: '',
        sub: [
          {
            type: 'input',
            label: `区域名称`,
            paramName: 'areaName',
            initialValue: initDataArea.areaName,
            span: 12,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'input',
            label: `区域编码`,
            paramName: 'areaCode',
            initialValue: initDataArea.areaCode,
            span: 11,
            offset: 1,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'select',
            label: `标签类型`,
            paramName: 'tagType',
            initialValue: initDataArea.tagType || '无标签',
            span: 12,
            width: 210,
            option: [
              {text: '无标签', value: '无标签'},
              {text: '二维码', value: '二维码'},
              {text: 'NFC', value: 'NCF'},
            ],
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'input',
            label: `区域电话`,
            paramName: 'phone',
            initialValue: initDataArea.phone,
            span: 11,
            offset: 1,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'input',
            label: '区域负责人',
            paramName: 'principal',
            initialValue: initDataArea.principal,
            span: 12,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'input',
            label: '设备总数',
            paramName: 'deviceNumber',
            initialValue: initDataArea.deviceNumber,
            span: 11,
            offset: 1,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'input',
            label: `巡检仪数量`,
            paramName: 'detectorNumber',
            initialValue: initDataArea.detectorNumber,
            span: 12,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
        ]
      }
    ]
  },

  itemsModalFactor(initDataFactor) {
    return [
      {
        title: '',
        sub: [
          {
            type: 'input',
            label: `厂名称`,
            paramName: 'factoryName',
            initialValue: initDataFactor.factoryName,
            span: 12,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'input',
            label: `厂编码`,
            paramName: 'factoryCode',
            initialValue: initDataFactor.factoryCode,
            span: 11,
            offset: 1,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'select',
            label: `标签类型`,
            paramName: 'tagType',
            initialValue: initDataFactor.tagType,
            span: 12,
            width: 210,
            option: [
              {text: '无标签', value: '无标签'},
              {text: '二维码', value: '二维码'},
              {text: 'NFC', value: 'NCF'},
            ],
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'input',
            label: `厂电话`,
            paramName: 'phone',
            initialValue: initDataFactor.phone,
            span: 11,
            offset: 1,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'input',
            label: '厂负责人',
            paramName: 'principal',
            initialValue: initDataFactor.principal,
            span: 12,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'input',
            label: '设备总数',
            paramName: 'deviceNumber',
            initialValue: initDataFactor.deviceNumber,
            span: 11,
            offset: 1,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'input',
            label: `巡检仪数量`,
            paramName: 'detectorNumber',
            initialValue: initDataFactor.detectorNumber,
            span: 12,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
        ]
      }
    ]
  },

  /**
   * 以下为 设备管理部分
   * **/
  extraBtnDevice: [],
  // 搜索条件
  itemsDevice (deviceNameDown){
    return [
      {
        type: 'select',
        label: '设备名称:',
        placeholder: '请输入 ..',
        paramName: 'deviceName',
        options: [{text: '全部', value: ''},...deviceNameDown]
      },
    ]
  },
  // 表格columns
  columnsDevice(read, edit) {
    return [
      {
        dataIndex: 'num',
        key: 'num',
        title: '序号',
        width: 50
      },
      {
        dataIndex: 'areaName',
        key: 'areaName',
        title: '区域',
        width: 150
      },
      {
        dataIndex: 'deviceName',
        key: 'deviceName',
        title: '设备名称',
        width: 150,
      },
      {
        dataIndex: 'handle',
        key: 'handle',
        title: '操作',
        width: 100,
        render(text, record) {
          return (
            <div>
              <MyIcon type="icon-chakan" onClick={read.bind(this, record)}
                      style={{fontSize: 18, color: '#16b8be', verticalAlign: 'center'}}/>
              <span style={{position: 'relative', bottom: 2}}> | </span>
              <MyIcon type="icon-bianji"
                      onClick={edit.bind(this, record)}
                      style={{
                        fontSize: 18,
                        color: '#16b8be',
                        marginLeft: 2
                      }}/>
            </div>
          )
        }
      },
    ]
  },

  // 模态框数据;
  itemsModalDevice(initDataDevice, deviceTypeNameDown,areaNameDown) {
    return [
      {
        title: '',
        sub: [
          {
            type: 'select',
            label: `设备区域`,
            paramName: 'areaId',
            initialValue: initDataDevice.areaId || areaNameDown[0].value,
            span: 12,
            width: 210,
            rules: [],
            option:areaNameDown
            // addonAfter: '后缀'
          },
          {
            type: 'input',
            label: `设备编码`,
            paramName: 'deviceCode',
            initialValue: initDataDevice.deviceCode,
            span: 11,
            offset: 1,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'input',
            label: `设备名称`,
            paramName: 'deviceName',
            initialValue: initDataDevice.deviceName,
            span: 12,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'select',
            label: `标签类型`,
            paramName: 'tagType',
            initialValue: initDataDevice.tagType || '无标签',
            span: 11,
            offset: 1,
            width: 210,
            option: [
              {text: '无标签', value: '无标签'},
              {text: '二维码', value: '二维码'},
              {text: 'NFC', value: 'NCF'},
            ],
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'datePicker',
            label: `安装时间`,
            paramName: 'installTime',
            initialValue: initDataDevice.installTime,
            span: 12,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'datePicker',
            label: `投运时间`,
            paramName: 'operationTime',
            initialValue: initDataDevice.operationTime,
            span: 11,
            offset: 1,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'input',
            label: `设备型号`,
            paramName: 'deviceTag',
            initialValue: initDataDevice.deviceTag,
            span: 12,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'select',
            label: `设备类型`,
            paramName: 'deviceType',
            initialValue: initDataDevice.deviceType || deviceTypeNameDown[0] && deviceTypeNameDown[0].value,
            span: 11,
            offset: 1,
            width: 210,
            rules: [],
            option: deviceTypeNameDown
            // addonAfter: '后缀'
          },
          {
            type: 'select',
            label: `基本类型`,
            paramName: 'basicType',
            initialValue: initDataDevice.basicType || '刚性基础',
            span: 12,
            width: 210,
            rules: [],
            option: [
              {value: '刚性基础', text: '刚性基础'},
              {value: '柔性基础', text: '柔性基础'}
            ]
            // addonAfter: '后缀'
          },
          {
            type: 'input',
            label: `功率( KW )`,
            paramName: 'power',
            initialValue: initDataDevice.power,
            span: 11,
            offset: 1,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'input',
            label: `转速(转/分钟)`,
            paramName: 'rotateSpeed',
            initialValue: initDataDevice.rotateSpeed,
            span: 12,
            width: 210,
            rules: [],
            // addonAfter: '后缀'
          },
          {
            type: 'textArea',
            label: `备注`,
            paramName: 'remark',
            initialValue: initDataDevice.remark,
            span: 24,
            width: 490,
            rules: [],
            autosize: {minRows: 3}
            // addonAfter: '后缀'
          },
        ]
      }
    ]
  },
}
